home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / isamexpt.zip / ISAMBROW.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-13  |  21KB  |  588 lines

  1. unit Isambrow;
  2. {copyright 1995 by Norbert Stellberg GmbH,
  3.  parts that are signed with a "*" copyright by TURBO POWER
  4.  or Michael Williams CompuServe: 71552,757 }
  5. interface
  6.  
  7. uses
  8.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  9.   Forms, Dialogs, ExtCtrls, Fvcbrows, Filer, IsamTabl;
  10.  
  11. type
  12.   Feld_GetProc = Function(Feld: Integer;
  13.                           Table: TIsamTable;
  14.                           var DATA): String;
  15.   {FELD_GETPROC will be created by the expert in
  16.    the browser-unit.
  17.    It will get the data-fields from your record.
  18.    Example:
  19.      Function TestGetFeldProc(Feld: Integer; Table: TIsamTable; var DATA): String; far;
  20.      var S: String;
  21.      begin
  22.        S:= '';
  23.        With TESTRECORD(Data) do begin
  24.        Case Feld of
  25.          1: s:= String_oem2ansi(Table.AnsiConvert,NAME1)+'^';
  26.          2: s:= String_oem2ansi(Table.AnsiConvert,NAME2)+'^';
  27.          3: s:= String_oem2ansi(Table.AnsiConvert,STREET)+'^';
  28.          4: s:= String_oem2ansi(Table.AnsiConvert,ZIP)+'^';
  29.          5: s:= String_oem2ansi(Table.AnsiConvert,CITY)+'^';
  30.          6: s:= DateStr(DATE)+'^';
  31.          7: s:= FormDezStr(AGE,10);
  32.       end;
  33.     end;
  34.     Result:= S;
  35.   end;   }
  36.  
  37.   TIsamBrowser = class(TFvcBrowser)
  38.     {a descendant of the TFVCBROWSER-Object, whose copyright is
  39.      by TURBO POWER INC.
  40.      Vars and Procs, signed by a "*" are copied from the TFVCBROWSER.
  41.      the copyright will still be held by TURBO POWER}
  42.   private
  43.     { Private declarations }
  44.     FHeader         : THeader;      {a normal header for your browser}
  45.     FSpalten        : TStringList;  {a list of TUEBERSCHRIFTOBJECTS .. see ISBRINST.INT}
  46.     FTable          : TIsamTable;   {the isamtable, that will be browsed}
  47.     FKeySection     : integer; { * Which header section are we searching on }
  48.     FSeparatorChar  : char;    { * Default '^'  }
  49.     FJustLeftChar   : char;    { * Default #255 }
  50.     FJustRightChar  : char;    { * Default #255 }
  51.     FJustCenterChar : char;    { * Default #255 }
  52.     FAllowIncss     : boolean; { * }
  53.     FIncSSColor     : TColor;  { * }
  54.     FIncSSTxtColor  : TColor;  { * }
  55.     Procedure SetTable(const Value: TIsamTable);
  56.     Procedure SetSpalten(const Value: TStringList);
  57.   protected
  58.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  59.     procedure KeyPress(var Key: Char); override;
  60.     function  WriteStringOut(var S      : string;
  61.                                  LineNr : word;
  62.                                  XOfs   : integer): word; override;
  63.     procedure ShowErrorOccured(EClass: Integer); override;
  64.   public
  65.     BaseLKey    : IsamKeyStr; { * }
  66.     BaseHKey    : IsamKeyStr; { * }
  67.     IncSS       : IsamKeyStr;  { * Incremental search string }
  68.     FTextMargin : TRect;      { * }
  69.     Procedure ResizeHeader;  {must be called after you changed the
  70.                               field widths by drag and drop in your
  71.                               browser}
  72.     Function ReadIni: Integer; {will read browser-settings from an ini-file,
  73.                                {must be called after creating the form and
  74.                                 before showing the browser-form.}
  75.     Procedure SetupBrowser(aParent: TForm); {will show the browser-setup-dialog,
  76.                                 see ISBRINST.INT}
  77.     Function GetRow(GetProc: Feld_GetProc; var DATA):String;
  78.                               {called by the browser to show the data fields}
  79.     Function GetLowBrowser: PLowWinBrowser;
  80.   published
  81.     { Published declarations }
  82.     constructor Create(AOwner: TComponent); override;
  83.     destructor Destroy; override;
  84.     property BrowserHeader  : THeader read FHeader write FHeader;
  85.     property Spalten        : TStringList read FSpalten write SetSpalten;
  86.     property Table          : TIsamTable read FTable write SetTable;
  87.     property KeySection     : {*}integer read FKeySection write FKeySection;
  88.     property SeparatorChar  : {*}char read FSeparatorChar write FSeparatorChar;
  89.     property JustLeftChar   : {*}char read FJustLeftChar write FJustLeftChar;
  90.     property JustRightChar  : {*}char read FJustRightChar write FJustRightChar;
  91.     property JustCenterChar : {*}char read FJustCenterChar write FJustCenterChar;
  92.     property AllowIncSS     : {*}boolean read FAllowIncSS write FAllowIncSS;
  93.     property IncSSColor     : {*}TColor read FIncSSColor write FIncSSColor;
  94.     property IncSSTxtColor  : {*}TColor read FIncSSTxtColor write FIncSSTxtColor;
  95.     procedure ClearIncss;     {*}
  96.   end;
  97.  
  98. procedure Register;
  99. Function GetAppName: String;  {procedure, to get the name of your application during runtime}
  100.  
  101. implementation
  102.  
  103. Uses UToolDll, IniFiles, IsBrInst;
  104.  
  105. Var AppName: String;
  106.  
  107. Function GetAppName: String;
  108. var G: String;
  109.     xPos: Integer;
  110. begin
  111.   G:= Application.ExeName;
  112.   xPos:= Pos('\',G);
  113.   While xPos > 0 do begin
  114.     Delete(G,1,xPos);
  115.     xPos:= Pos('\',G);
  116.   end;
  117.   xPos:= Pos('.',G);
  118.   if xPos > 0 then G:= Copy(G,1,xPos-1);
  119.   AppName:= G;
  120.   GetAppName:= G;
  121. end;
  122.  
  123. constructor TIsamBrowser.Create(AOwner : TComponent);
  124. begin
  125.   Inherited Create(AOwner);
  126.   IncSS := '';
  127.   SeparatorChar := '^';
  128.   FJustLeftChar := #255;
  129.   FJustCenterChar := #255;
  130.   FJustRightChar := #255;
  131.   BaseLKey := LowKey;
  132.   BaseHKey := HighKey;
  133.   FIncSSColor := clRed;
  134.   FIncssTxtColor := clWhite;
  135.   FSpalten:= TStringList.Create;
  136. end;
  137.  
  138. Function TIsamBrowser.GetLowBrowser: PLowWinBrowser;
  139. begin
  140.   Result:= BrowserPtr;
  141. end;
  142.  
  143. Destructor TIsamBrowser.Destroy;
  144. begin
  145.   FSpalten.Free;
  146.   Inherited Destroy;
  147. end;
  148.  
  149. Function TIsamBrowser.ReadIni: Integer;
  150. var BrwListe,SListe: TStringList;
  151.     BrwIni: TIniFile;
  152.     FNr,K,i,Code,idx,Arr1,Arr2,Feld: Integer;
  153.     SStr,AktDir,LStr,LenStr,FeldName: String;
  154.     x,Len: Longint;
  155. begin
  156.   AktDir:= ExtractFilePath(Application.ExeName);
  157.   K:= 1;
  158.   BrwIni:= TIniFile.Create(AktDir + GetAppName+'.INI');
  159.   BrwListe:= TStringList.Create;
  160.   SListe:= TStringList.Create;
  161.   K:= BrwIni.ReadInteger(Name+'Key','KeyNo',1);
  162.   BrwIni.ReadSection(Name,BrwListe);
  163.   if BrwListe.Count > 0 then begin
  164.     For i:= 0 to BrwListe.Count-1 do begin
  165.       LStr:= BrwIni.ReadString(Name,BrwListe[i],'');
  166.       if Pos(',',LStr) > 0 then begin
  167.         Val(Copy(LStr,1,Pos(',',LStr)-1),Len,Code);
  168.         Delete(LStr,1,Pos(',',LStr));
  169.         Val(LStr,Idx,Code);
  170.       end
  171.       else begin
  172.         Idx:= i+1;
  173.         Val(LStr,Len,Code);
  174.       end;
  175.       SListe.AddObject(BrwListe[i],TUeberschriftObject.Init(BrwListe[i],Idx,Len));
  176.     end;
  177.     Spalten:= SListe;
  178.   end
  179.   else begin
  180.     if Table <> NIL then begin
  181.       if Table.IsamRecord.Count > 0 then begin
  182.         FNr:= 0;
  183.         For i:= 0 to Table.IsamRecord.Count-1 do begin
  184.           SStr:= Table.IsamRecord[i];
  185.           if (Pos('DUMMY',Uppercase(SStr)) = 0) and (Pos('IGNORE',Uppercase(SStr)) = 0) then begin
  186.             Len:= 0;
  187.             if Pos(':',SStr) > 0 then begin
  188.               GetArray(SStr,Arr1,Arr2);
  189.               For Feld:= Arr1 to Arr2 do begin
  190.                 FeldName:= Copy(SStr,1,Pos(':',SStr)-1);
  191.                 Strip(FeldName);
  192.                 if Arr1 <> Arr2 then FeldName:= FeldName + DezStr(Feld);
  193.                 LenStr:= Uppercase(SStr);
  194.                 Delete(LenStr,1,Pos(':',LenStr));
  195.                 Strip(LenStr);
  196.                 if Pos('ARRAY[',LenStr) > 0 then begin
  197.                   Delete(LenStr,1,Pos('ARRAY[',LenStr));
  198.                   Delete(LenStr,1,Pos(']',LenStr));
  199.                 end;
  200.                 if Pos('STRING',LenStr) > 0 then begin
  201.                   if Pos('[',LenStr) > 0 then begin
  202.                     Delete(LenStr,1,Pos('[',LenStr));
  203.                     LenStr:= Copy(LenStr,1,Pos(']',LenStr)-1);
  204.                     Val(LenStr,Len,Code);
  205.                   end
  206.                   else Len:= 255;
  207.                 end
  208.                 else if Pos('INTEGER',LenStr) > 0 then Len:= 8
  209.                 else if Pos('WORD',LenStr) > 0 then Len:= 8
  210.                 else if Pos('BYTE',LenStr) > 0 then Len:= 4
  211.                 else if Pos('LONGINT',LenStr) > 0 then Len:= 10
  212.                 else if Pos('REAL',LenStr) > 0 then Len:= 10;
  213.                 {if Len > 0 then begin}
  214.                 Inc(FNr);
  215.                 SListe.AddObject(FeldName,TUeberschriftObject.Init(FeldName,FNr,Len));
  216.                 {end;}
  217.               end;
  218.             end;
  219.           end;
  220.         end;
  221.         Spalten:= SListe;
  222.       end;
  223.     end;
  224.   end;
  225.   SListe.Free;
  226.   BrwListe.Free;
  227.   BrwIni.Free;
  228.   Result:= K;
  229. end;
  230.  
  231. (*Function TIsamBrowser.GetRow(GetProc: Feld_GetProc; var DATA):String;
  232. var S: String;
  233.     i,X,Code: Integer;
  234.     U:TUeberschriftObject;
  235. begin
  236.   S:= '';
  237.   For i:= 0 to Spalten.Count-1 do begin
  238.     if Spalten.Objects[i] <> NIL then begin
  239.       U:= TUeberschriftObject(Spalten.Objects[i]);
  240.       X:= U.Idx;
  241.       if (X > 0) and (U.Breite > 0) then S:= S + GetProc(X,Table,DATA);
  242.     end;
  243.   end;
  244.   Result:= ' '+S+#13
  245. end;*)
  246. Function TIsamBrowser.GetRow(GetProc: Feld_GetProc; var DATA):String;
  247. var S: String;
  248.     ss : String; {NS}
  249.     i,X,Code : Integer;
  250.     L,ii: Integer; {NS}
  251.     U:TUeberschriftObject;
  252.     SChar: Char;
  253. begin
  254.   S:= '';
  255.   SChar:= SeparatorChar;
  256.   For i:= 0 to Spalten.Count-1 do begin
  257.     if Spalten.Objects[i] <> NIL then begin
  258.       U:= TUeberschriftObject(Spalten.Objects[i]);
  259.       X:= U.Idx;
  260.       L := U.Breite; {NS}
  261.       ss := GetProc(X,Table,DATA); {NS}
  262.       ii := Pos(SChar,ss); {NS}
  263.       if ii > 0 then delete(ss,ii,1); {NS}
  264.       ss := F(SS,L)+SChar; {NS}  {Ich bin davon ausgegangen, da▀ das Feld die LΣnge L hat zuzⁿglich das Zeichen
  265.                                ^. Das Zeichen ^ habe ich entfernt, den String auf die LΣnge L aufgefⁿllt und das Zeichen
  266.                                ^ wieder angefⁿgt. Beachte bitte, das das Zeichen ^ variabel ist und im Browser eingestellt
  267.                                werden kann. }
  268.       if (X > 0) and (U.Breite > 0) then S:= S + ss; {NS}
  269.     end;
  270.   end;
  271.   Result:= ' '+S+#13
  272. end;
  273.  
  274. Procedure TIsamBrowser.SetupBrowser(aParent: TForm);
  275. begin
  276.   BrowserSetup(aParent,GetAppName,Name,Table);
  277.   ReadIni;
  278.   SetAndUpDateBrowserScreen('',0);
  279. end;
  280.  
  281. Procedure TIsamBrowser.SetTable(Const Value: TIsamTable);
  282. var FNr,i,Len,Code,Feld,Arr1,Arr2: Integer;
  283.     SStr,FeldName,LenStr: String;
  284.     SListe: TStringList;
  285. begin
  286.   FTable:= Value;
  287.   if (csDesigning in ComponentState) then begin
  288.     if Assigned(Value) then begin
  289.       if FSpalten.Count = 0 then begin
  290.         if Value.IsamRecord.Count > 0 then begin
  291.           SListe:= TStringList.Create;
  292.           FNr:= 0;
  293.           For i:= 0 to Value.IsamRecord.Count-1 do begin
  294.             SStr:= Value.IsamRecord[i];
  295.             if (Pos('DUMMY',Uppercase(SStr)) = 0) and (Pos('IGNORE',Uppercase(SStr)) = 0) then begin
  296.               Len:= 0;
  297.               if Pos(':',SStr) > 0 then begin
  298.                 GetArray(SStr,Arr1,Arr2);
  299.                 For Feld:= Arr1 to Arr2 do begin
  300.                   FeldName:= Copy(SStr,1,Pos(':',SStr)-1);
  301.                   Strip(FeldName);
  302.                   if Arr1 <> Arr2 then FeldName:= FeldName + DezStr(Feld);
  303.                   LenStr:= Uppercase(SStr);
  304.                   Delete(LenStr,1,Pos(':',LenStr));
  305.                   Strip(LenStr);
  306.                   if Pos('ARRAY[',LenStr) > 0 then begin
  307.                     Delete(LenStr,1,Pos('ARRAY[',LenStr));
  308.                     Delete(LenStr,1,Pos(']',LenStr));
  309.                   end;
  310.                   if Pos('STRING',LenStr) > 0 then begin
  311.                     if Pos('[',LenStr) > 0 then begin
  312.                       Delete(LenStr,1,Pos('[',LenStr));
  313.                       LenStr:= Copy(LenStr,1,Pos(']',LenStr)-1);
  314.                       Val(LenStr,Len,Code);
  315.                     end
  316.                     else Len:= 255;
  317.                   end
  318.                   else if Pos('INTEGER',LenStr) > 0 then Len:= 8
  319.                   else if Pos('WORD',LenStr) > 0 then Len:= 8
  320.                   else if Pos('BYTE',LenStr) > 0 then Len:= 4
  321.                   else if Pos('LONGINT',LenStr) > 0 then Len:= 10
  322.                   else if Pos('REAL',LenStr) > 0 then Len:= 10;
  323.                   {if Len > 0 then begin}
  324.                     Inc(FNr);
  325.                     SListe.AddObject(FeldName,TUeberschriftObject.Init(FeldName,FNr,Len));
  326.                   {end;}
  327.                 end;
  328.               end;
  329.             end;
  330.           end;
  331.           Spalten:= SListe;
  332.           SListe.Free;
  333.         end;
  334.       end;
  335.     end;
  336.   end;
  337. end;
  338.  
  339. procedure TIsamBrowser.SetSpalten(const Value: TStringList);
  340. var N,i,xLen,Code: Integer;
  341.     SStr,TStr: String;
  342. begin
  343.   FSpalten.Assign(Value);
  344.   if BrowserHeader <> NIL then BrowserHeader.Sections.Clear;
  345.   if Value <> NIL then begin
  346.     if FSpalten.Count > 0 then begin
  347.       n:= 0;
  348.       for i:= 0 to FSpalten.Count-1 do begin
  349.         if FSpalten.Objects[i] <> NIL then begin
  350.           with TUeberschriftObject(FSpalten.Objects[i]) do begin
  351.             SStr:= Txt;
  352.             xLen:= Breite;
  353.             if xLen > 0 then begin
  354.               if BrowserHeader <> NIL then begin
  355.                 BrowserHeader.Sections.Insert(N,SStr);
  356.                 BrowserHeader.SectionWidth[N]:= (xLen * 7)+8;
  357.                 inc(N);
  358.               end;
  359.             end;
  360.           end;
  361.         end;
  362.       end;
  363.     end;
  364.   end;
  365. end;
  366.  
  367. Procedure TIsamBrowser.ResizeHeader;
  368. var idx,I,K,Len,x: Integer;
  369.     AktDir,SStr: String;
  370.     SListe: TStringList;
  371.     BrwIni: TIniFile;
  372.     U: TUeberschriftObject;
  373. begin
  374.   AktDir:= ExtractFilePath(Application.ExeName);
  375.   if BrowserHeader <> NIL then begin
  376.     if BrowserHeader.Sections.Count > 0 then begin
  377.       SListe:= TStringList.Create;
  378.       BrwIni:= TIniFile.Create(AktDir + GetAppname+'.INI');
  379.       if Table <> NIL then K:= Table.KeyNo else K:= 1;
  380.       BrwIni.WriteInteger(Name+'Key','KeyNo',K);
  381.       if Spalten.Count > 0 then begin
  382.         for i:= 0 to Spalten.Count-1 do begin
  383.           if Spalten.Objects[i] <> NIL then begin
  384.             U:= TUeberschriftObject(Spalten.Objects[i]);
  385.             x:= BrowserHeader.Sections.Indexof(Spalten[i]);
  386.             if x > -1 then begin
  387.               Len:= Round((BrowserHeader.SectionWidth[x]-8)/7);
  388.               if Len < 0 then Len:= 0;
  389.               SStr:= BrowserHeader.Sections[x];
  390.               Idx:= U.Idx;
  391.               SListe.AddObject(SStr, TUeberschriftObject.Init(SStr,idx,Len));
  392.               SStr:= DezStr(Len)+','+DezStr(idx);
  393.               if Len > 0 then BrwIni.WriteString(Name,BrowserHeader.Sections[x],SStr);
  394.             end
  395.             else begin
  396.               SStr:= U.Txt;
  397.               Len:= U.Breite;
  398.               Idx:= U.idx;
  399.               SListe.AddObject(SStr,TueberschriftObject.Init(SStr,idx,Len));
  400.             end;
  401.           end
  402.           else Errorwindow('Object is NIL',Spalten[i]);
  403.         end;
  404.       end
  405.       else Errorwindow('Spalte is NIL','');
  406.       Spalten:= SListe;
  407.       SListe.Free;
  408.       BrwIni.Free;
  409.     end;
  410.   end;
  411.   ReadIni;
  412.   SetAndUpdateBrowserScreen('', 0);
  413. end;
  414.  
  415. procedure TIsamBrowser.ShowErrorOccured(EClass: Integer);
  416. begin
  417.   if EClass > 1 then Inherited showErrorOccured(EClass);
  418. end;
  419.  
  420. procedure TIsamBrowser.ClearIncSS;
  421. begin
  422.   { Make sure to call this before going to a new key number }
  423.   IncSS := '';
  424.   LowKey := BaseLKey;
  425.   HighKey := BaseHKey;
  426. end;
  427.  
  428. function TIsamBrowser.WriteStringOut(var S : string;
  429.                                          LineNr : word;
  430.                                          XOfs : integer) : word;
  431. var
  432.     SegmentString  : string;
  433.     Just,i,j    : integer;
  434.     Rect   : TRect;
  435.     x   : integer;
  436.     SegNum : integer;
  437.     SaveFontColor,
  438.     SaveColor : TColor;
  439.  
  440.     function StUpCase(St : string) : string;
  441.     var i : integer;
  442.     begin
  443.       Result := st;
  444.       for i := 1 to length(st) do result[i] := upcase(result[i]);
  445.     end;
  446.  
  447. begin
  448.   Result := GetTextOutPosY(LineNr);
  449.  
  450.   Rect.Left := 0{1};
  451.   Rect.Top := Result;
  452.   Rect.Bottom := Result + TotalCharHeight;
  453.  
  454.   if Assigned(FHeader) then
  455.     Rect.Right := BrowserHeader.Width
  456.   else
  457.     Rect.Right := Width;
  458.  
  459.   Canvas.FillRect(Rect);
  460.  
  461.   SegmentString := '';
  462.   SegNum := 0;
  463.  
  464.   if Assigned(FHeader) then begin
  465.      BrowserHeader.Left := xOfs + Left;
  466.      BrowserHeader.Width := Width - xOfs;
  467.   end;
  468.  
  469.   Just := DT_Left;
  470.   for i := 1 to length(S) do begin
  471.     if (S[i] = JustLeftChar) then Just := DT_left else
  472.     if (S[i] = JustCenterChar) then Just := DT_Center else
  473.     if (S[i] = JustRightChar) then Just := DT_Right else
  474.     if (S[i] = SeparatorChar) or (i = length(S)) then begin
  475.       if i = length(S) then SegmentString := SegmentString + S[i];
  476.       { SegmentString now contains the segment }
  477.       Rect.Top := Result;
  478.       Rect.Bottom := Result + TotalCharHeight;
  479.       x := 1;
  480.       if Assigned(FHeader) then begin
  481.          for j := 0 to SegNum-1 do
  482.           x := x + BrowserHeader.SectionWidth[j];
  483.          Rect.Left := XOfs + FTextMargin.Left + x + 2;
  484.          if SegNum = BrowserHeader.Sections.Count-1 then
  485.            Rect.Right := Rect.Left + BrowserHeader.SectionWidth[SegNum]-20
  486.          else
  487.            Rect.Right := Rect.Left + BrowserHeader.SectionWidth[SegNum]-4;
  488.       end else begin
  489.          Rect.Left := XOfs + FTextMargin.Left + 2;
  490.          Rect.Right := XOfs + FtextMargin.Left + Width - 2;
  491.       end;
  492.  
  493.       { Draw the text }
  494.       DrawText(Canvas.Handle,@SegmentString[1],length(SegmentString),Rect,Just+DT_NoPrefix);
  495.  
  496.       { Process the incremental search string }
  497.       if (IncSS <> '') and (SegNum = KeySection) and (Just = DT_Left) and
  498.          (copy(StUpCase(SegmentString),1,Length(IncSS)) = IncSS) then begin
  499.            { Do incremental search string highlight }
  500.            SaveColor := Canvas.Brush.Color;
  501.            SaveFontColor := Canvas.Font.Color;
  502.            Canvas.Font.Color := IncSSTxtColor;
  503.            Canvas.Brush.Color := IncSSColor;
  504.            DrawText(Canvas.Handle,@SegmentString[1],length(IncSS),Rect,DT_Left+Dt_NoPrefix);
  505.            Canvas.Font.Color := SaveFontColor;
  506.            Canvas.Brush.Color := SaveColor;
  507.       end;
  508.       { Draw vertical lines }
  509.       Canvas.Pen.Color := clGray;
  510.       Rect.Right := Rect.Right + 2;
  511.       Canvas.MoveTo(Rect.Right-2,Rect.Top);
  512.       Canvas.LineTo(Rect.Right-2,Rect.Bottom);
  513.       Canvas.Pen.Color := clWhite;
  514.       Canvas.MoveTo(Rect.Right-1,Rect.Top);
  515.       Canvas.LineTo(Rect.Right-1,Rect.Bottom);
  516.       inc(SegNum);
  517.       SegmentString := '';
  518.     end else begin
  519.       SegmentString := SegmentString + S[i];
  520.     end;
  521.   end;
  522. end;
  523.  
  524. procedure TIsamBrowser.KeyDown(var Key: Word; Shift: TShiftState);
  525. var Data,Dup: Pointer;
  526. begin
  527.   inherited KeyDown(Key, Shift);
  528.   if CanCallLowBrowser then begin
  529.     case Key of
  530.       vk_Delete: if Table <> NIL then begin
  531.                    Table.Ref:= GetCurrentDatRef;
  532.                    GetMem(Data,Table.RecSize);
  533.                    GetMem(Dup,Table.RecSize);
  534.                    Table.Get(Data^,Dup^);
  535.                    Table.Delete(Data^,Dup^);
  536.                    FreeMem(Dup,Table.RecSize);
  537.                    FreeMem(Data,Table.RecSize);
  538.                    SetAndUpdateBrowserScreen(Table.Key,Table.Ref);
  539.                  end;
  540.       vk_Insert: OnDblClick(Self);
  541.     end;
  542.   end;
  543. end;
  544.  
  545. procedure TIsamBrowser.KeyPress(var Key : char);
  546. Const AllowedKeys = [' '..'z'];
  547. var SaveIncSS, SaveLowKey, SaveHighKey : IsamKeyStr;
  548. begin
  549.   if not AllowIncss then Exit;
  550.   SaveIncSS := IncSS;
  551.   if Key = #8 then begin { Backspace }
  552.     if IncSS <> '' then Delete(IncSS,Length(IncSS),1);
  553.   end else begin
  554.     if Key in AllowedKeys then IncSS := IncSS + UpCase(Key)
  555.     else begin
  556.       Messagebeep(0);
  557.       Exit;
  558.     end;
  559.   end;
  560.   if not CanCallLowBrowser then Exit;
  561.   { Changing either the low or the high key can cause use to not have any
  562.     records left to show, so if either fails, we need to undo the changes. }
  563.   try
  564.     SaveLowKey := LowKey;
  565.     LowKey := BaseLKey + IncSS;
  566.     try
  567.        SaveHighKey := HighKey;
  568.        HighKey := BaseHKey + IncSS;
  569.     except
  570.        HighKey := SaveHighKey;
  571.        LowKey := SaveLowKey;
  572.        IncSS := SaveIncSS;
  573.        MessageBeep(0);
  574.     end;
  575.   except
  576.     LowKey := SaveLowKey;
  577.     IncSS := SaveIncSS;
  578.     MessageBeep(0);
  579.   end;
  580. end;
  581.  
  582. procedure Register;
  583. begin
  584.   RegisterComponents('B-Tree Filer', [TIsamBrowser]);
  585. end;
  586.  
  587. end.
  588.